from distutils.command.config import config
import os
from xmlrpc.client import SERVER_ERROR


class Config:
    # 配置Mysql参数
    MYSQL_DIALECT = 'mysql'
    MYSQL_DIRVER = 'pymysql'
    MYSQL_NAME = 'root'
    MYSQL_PWD = 'root'
    MYSQL_HOST = 'localhost'
    MYSQL_PORT = 3306
    MYSQL_DB = 'flask_shop'
    MYSQL_CHARSET = 'utf8mb4'


    # SQLALCHEMY_DATABAER_URI = 'mysql+pymysql://root:root@localhost:3306/shop_env?charset=utf8mb4'
    SQLALCHEMY_DATABASE_URI = f'{MYSQL_DIALECT}+{MYSQL_DIRVER}://{MYSQL_NAME}:{MYSQL_PWD}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DB}?charset={MYSQL_CHARSET}'
    SQLALCHEMY_TRACK_MODIFICATIONS = True


    # 加盐  os.urandom 随机数
    SECRET_KEY = os.urandom(16)
    
    ALLOWED_IMGS = set(["bmp","png","jpg","jpeg","gif"])
    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    SERVER_IMG_UPLOADS = os.path.join(BASE_DIR,"flask_shop","static","img")

class DevelopmentConfig(Config):
    DEBUG = True
class ProductionConfig(Config):
    pass

config_map={
    'develop':DevelopmentConfig,
    "product":ProductionConfig
}